package com.example.backend.util;

/**
 * 报文格式工具
 * @author 李月
 * @date 2022/4/13 21:31
 */
public class ResultGenerator {
    private static final int RESULT_CODE_SUCCESS = 200;
    private static final int RESULT_CODE_ERROR = 400;

    public static Result genSuccessResult(String message, Object data) {
        Result result = new Result();
        result.setResultCode(RESULT_CODE_SUCCESS);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static Result genFailResult(String message, Object data) {
        Result result = new Result();
        result.setResultCode(RESULT_CODE_ERROR);
        result.setMessage(message);
        result.setData(data);
        return result;
    }
}
